package cn.edu.neusoft.maxingxin231.yuejian06.Fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseFragment extends Fragment {
    protected  int layout_file = 0;
    View view = null;
    protected abstract void initView();
    abstract void initEvent();
    abstract void initData();
    public int getLayout_file(){
        return layout_file;
    }
    public void setLayout_file(int layout_file){this.layout_file = layout_file;}
    public BaseFragment(){

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view =inflater.inflate(getLayout_file(),container,false);
        initView();
        initEvent();
        initData();
        return view;
    }

    public String getUser_name(){
        SharedPreferences sp;
        sp=getActivity().getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("username","");
    }

    public String getUser_passwd(){
        SharedPreferences sp;
        sp=getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("userpass","");
    }

    public Boolean getUser_remember(){
        SharedPreferences sp;
        sp=getActivity().getSharedPreferences(
                "userInfo",Context.MODE_PRIVATE);
        return sp.getBoolean("remember",false);
    }
    public String getUser_id(){
        SharedPreferences sp;
        sp =getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("uid","");
    }
}
